<?php
/**
 * @package Admin
 * @author Henrique Droog <henridroog@gmail.com>
 * @name SubmenuForm
 * @since 02/04/2011
 * @version 1.0
 */
class Admin_Form_SubmenuForm extends Zend_Form{
    public function init(){

        $id = new Zend_Form_Element_Hidden('id');

        // Add an email element
        $titulo = new Zend_Form_Element_Text('name');
        $titulo->setLabel('Título')
                ->setRequired(true)
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty')
                ->addValidator('StringLength',false,array(0,75));

        // Add an email element
        $menus = new Admin_Model_MenuMapper();
        $combo = $menus->fetchAll();

        $comboMenu = array();
        $comboMenu[""] = "Selecione...";
        foreach ($combo as $c){
            $comboMenu[$c->id] = $c->name;
        }

        $menu = new Zend_Form_Element_Select('menu');
        $menu->setLabel('Menu')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->setMultiOptions($comboMenu);

        // Add an email element
        $modules = new Admin_Model_ModuleMapper();
        $comboM = $modules->fetchAll();

        $comboModule = array();
        $comboModule[""] = "Selecione...";
        foreach ($comboM as $c){
            $comboModule[$c->id] = $c->name;
        }

        $module = new Zend_Form_Element_Select('module');
        $module->setLabel('Módulo')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->setMultiOptions($comboModule);

        // Add an email element
        $modules = new Admin_Model_ControllerMapper();
        $comboC = $modules->fetchAll();

        $comboController = array();
        $comboController[""] = "Selecione...";
        foreach ($comboC as $c){
            $comboController[$c->id] = $c->name;
        }

        $controller = new Zend_Form_Element_Select('controller');
        $controller->setLabel('Controller:')
                ->setRequired(true)
                ->setAttrib('disable','disable')
                ->addValidator('NotEmpty')
                ->setMultiOptions($comboController);

        // Add an email element
        $modules = new Admin_Model_ActionMapper();
        $comboA = $modules->fetchAll();

        $comboAction = array();
        $comboAction[""] = "Selecione...";
        foreach ($comboA as $c){
            $comboAction[$c->id] = $c->name;
        }

        $action = new Zend_Form_Element_Select('action');
        $action->setLabel('Action:')
                ->setRequired(true)
                ->setAttrib('disable','disable')
                ->addValidator('NotEmpty')
                ->setMultiOptions($comboAction);

        $options['']='Selecione...';
        $options['true']='Ativo';
        $options['false']='Inativo';
        $ativo = new Zend_Form_Element_Select('status');
        $ativo->setLabel('Status')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->setMultiOptions($options);

        // Add the submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Enviar')
                ->setAttrib('ignore',true);


        $this->addElements( array($id,$titulo,$menu,$module,$controller,$action,$ativo,$submit) );
    }
}